class Solution {
    public String maximumBinaryString(String binary) {
        int n = binary.length();
        char[] arr = binary.toCharArray();
        int j = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i] == '0') {
                while (j <= i || (j < n && arr[j] == '1')) {
                    j++;
                }
                if (j < n) {
                    arr[j] = '1';
                    arr[i] = '1';
                    arr[i + 1] = '0';
                }
            }
        }
        return new String(arr);
    }
}